package com.restaurant.application.accumulate.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;

import java.util.List;

public class AccumulateData implements PickableBean {

    public static final String FN_CUSTOMERUID = "customerUID";
    public static final String FN_CREATETIME = "createTime";
    public static final String FN_MODIFYTIME = "modifyTime";
    public static final String FN_ACCUMULATE = "accumulate";
    public static final String FN_TYPE = "type";
    public static final String FN_DETAIL = "detail";
    public static final String FN_ORDERID = "orderId";
    public static final String FN_ACTION = "action";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_CUSTOMERUID,
            FN_CREATETIME,
            FN_MODIFYTIME,
            FN_ACCUMULATE,
            FN_TYPE,
            FN_DETAIL,
            FN_ORDERID,
            FN_ACTION);
    
    private UID customerUID;
    private Long createTime;
    private Long modifyTime;
    private Long accumulate;
    private String type;
    private UID detail;
    private String orderId;
    private String action;

    public AccumulateData(UID customerUID, Long createTime, Long modifyTime, Long accumulate, String type, UID detail, String orderId, String action) {
        setCustomerUID(customerUID);
        setCreateTime(createTime);
        setModifyTime(modifyTime);
        setAccumulate(accumulate);
        setType(type);
        setDetail(detail);
        setOrderId(orderId);
        setAction(action);
    }

    public AccumulateData() {
    }

    public AccumulateData duplicate() {
        AccumulateData result = new AccumulateData();
        result.customerUID = this.customerUID;
        result.createTime = this.createTime;
        result.modifyTime = this.modifyTime;
        result.accumulate = this.accumulate;
        result.type = this.type;
        result.detail = this.detail;
        result.orderId = this.orderId;
        result.action = this.action;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public UID getCustomerUID() {
        return customerUID;
    }

    public void setCustomerUID(UID value) {
        this.customerUID = value;
    }

    public AccumulateData withCustomerUID(UID value) {
        setCustomerUID(value);
        return this;
    }

    public AccumulateData withCustomerUID(UID value, UID defaultValue) {
        setCustomerUID(value == null ? defaultValue : value);
        return this;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long value) {
        this.createTime = value;
    }

    public AccumulateData withCreateTime(Long value) {
        setCreateTime(value);
        return this;
    }

    public AccumulateData withCreateTime(Long value, Long defaultValue) {
        setCreateTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Long value) {
        this.modifyTime = value;
    }

    public AccumulateData withModifyTime(Long value) {
        setModifyTime(value);
        return this;
    }

    public AccumulateData withModifyTime(Long value, Long defaultValue) {
        setModifyTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getAccumulate() {
        return accumulate;
    }

    public void setAccumulate(Long value) {
        this.accumulate = value;
    }

    public AccumulateData withAccumulate(Long value) {
        setAccumulate(value);
        return this;
    }

    public AccumulateData withAccumulate(Long value, Long defaultValue) {
        setAccumulate(value == null ? defaultValue : value);
        return this;
    }

    public String getType() {
        return type;
    }

    public void setType(String value) {
        this.type = value;
    }

    public AccumulateData withType(String value) {
        setType(value);
        return this;
    }

    public AccumulateData withType(String value, String defaultValue) {
        setType(value == null ? defaultValue : value);
        return this;
    }

    public UID getDetail() {
        return detail;
    }

    public void setDetail(UID value) {
        this.detail = value;
    }

    public AccumulateData withDetail(UID value) {
        setDetail(value);
        return this;
    }

    public AccumulateData withDetail(UID value, UID defaultValue) {
        setDetail(value == null ? defaultValue : value);
        return this;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String value) {
        this.orderId = value;
    }

    public AccumulateData withOrderId(String value) {
        setOrderId(value);
        return this;
    }

    public AccumulateData withOrderId(String value, String defaultValue) {
        setOrderId(value == null ? defaultValue : value);
        return this;
    }
    
    public String getAction() {
        return action;
    }

    public void setAction(String value) {
        this.action = value;
    }

    public AccumulateData withAction(String value) {
        setAction(value);
        return this;
    }

    public AccumulateData withAction(String value, String defaultValue) {
        setAction(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "customerUID":
                return getCustomerUID();
            case "createTime":
                return getCreateTime();
            case "modifyTime":
                return getModifyTime();
            case "accumulate":
                return getAccumulate();
            case "type":
                return getType();
            case "detail":
                return getDetail();
            case "orderId":
                return getOrderId();
            case "action":
                return getAction();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof AccumulateData)) return false;
        return signature().equals(((AccumulateData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean AccumulateData has no signature defined, no hash code or equals possible.");
    }
}
